﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using ZLDC.Common.Estate;
using System.Data;

namespace ZLDC.Estate.AM
{
    public partial class DeptList : _PageBase
    {
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                iStartDay.Value = DateTime.Today.ToString("yyyy-MM-dd");
                iEndDay.Value = DateTime.Today.ToString("yyyy-MM-dd");  
              
                string station = this.info.m_sStation;
                if ("分行经理,区域经理,分区经理,分行经理,营运总监,营运副总监,营业副总经理,营运总经理,营业总经理".Contains(station))
                {
                    spanPrompt.InnerHtml = "<font color='red'>注意：为提高系统性能，区经、总监当天的量化数据是3小时进行一次统计</font>";
                }
                if (!ZLDC.Common.BaseUser.UserInfo.GetPopedom("导出部门量化"))
                {
                    btnExport.Visible = false;
                }
            }
        }




        protected void btnExport_Click(object sender, EventArgs e)
        {


           string condition = Session["dept_list_report"].ToString();
           if (condition == "") 
           {
               return;
           }
           
           string Sql = "select deptId  as '部门编号', dept as '部门名称', SUM(hfollow)as '盘源跟进',SUM(cfollow)as '客源跟进'" +
                             ",SUM(look)as '待看提醒',SUM(looked)as '已带看(售)',SUM([mark3])as '已带看(租)',SUM(newhousing)as '新增盘(售)'" +
                             ",SUM([mark1])as '新增盘(租)'  " +
                             ",SUM(newcustomer)as '新增客(买)'" +
                              ",SUM([mark2])as '新增客(租)'" +
                             ",SUM(only)as '独家'" +
                             ",SUM(versa)as '反签'" +
                             ",SUM([key])as '钥匙'" +
                             ",SUM(telphone)as '查看电话' " +
                             ",SUM(hasphoto)as '上传图片盘源' " +
                             ",SUM(photo)as '上传图片数 '      " +
                             ",SUM([self])as '自看房源'    " +
                             ",SUM([mark4])as '新转客(买)'" +
                             ",SUM([mark5])as '新转客(租)'" +
                             ",SUM(visit) as '家访'   " +
                             ",SUM(EarnestMoney) as '诚意金'" +
                             ",SUM(talks) as '摆台'   " +
                             ",SUM(afterservice) as '售后服务'"+
                             "  from t_quantification as t " + condition + " group by deptId,dept order by deptId";
           
           
           PageExport.ExportDsToXls(this.Page,"report", Sql);
        }
       
    }
}
